Lazy(T) Constructor (Func(T), LazyThreadSafetyMode)

Task Parallel System.Threading

Initializes a new instance of the Lazy<(Of <(T>)>) class that uses a specified initialization function and a specified thread-safety mode.

Namespace:  System
Assembly:  System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
	valueFactory As Func(Of T), _
	mode As LazyThreadSafetyMode _
)
C#
public Lazy(
	Func<T> valueFactory,
	LazyThreadSafetyMode mode
)

Parameters

valueFactory
Type: System..::.Func<(Of <(T>)>)
The Func<(Of <(T>)>) invoked to produce the lazily-initialized value when it is needed.
mode
Type: System.Threading..::.LazyThreadSafetyMode
The lazy thread-safety mode.

Exceptions

ExceptionCondition
System..::.ArgumentNullExceptionvalueFactory is a null reference (Nothing in Visual Basic).
System..::.ArgumentOutOfRangeExceptionmode mode contains an invalid value.

See Also